| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

BufferCast.h
1 // BufferCast.h
3 //
5
6 namespace nkMemory
7 {
16 template <typename T = unsigned char>
17 class BufferCast
18 {
19 public :
20
21 // Constructors, destructor
25 BufferCast () noexcept = default ;
32 BufferCast (unsigned long long size) noexcept ;
39 BufferCast (T* data, unsigned long long size) noexcept ;
46 BufferCast (const Buffer& buffer) noexcept ;
53 BufferCast (Buffer&& buffer) noexcept ;
60 BufferCast (const BufferCast& cast) noexcept ;
67 BufferCast (BufferCast&& cast) noexcept ;
75 template <typename U = T>
76 BufferCast (std::enable_if_t<!std::is_class_v<U>, const Buffer&> buffer) noexcept ;
82 ~BufferCast () ;
83
84 public :
85
86 // Getters
90 T* getData () const ;
94 unsigned long long getSize () const ;
98 bool empty () const ;
102 T& front () ;
106 const T& front () const ;
110 T& back () ;
114 const T& back () const ;
118 T* begin () ;
122 const T* begin () const ;
126 T* end () ;
130 const T* end () const ;
131
132 public :
133
134 // Management
138 BufferCast<T>& clear () ;
145 BufferCast<T>& resize (unsigned long long size) ;
153 T& append (const T& value) ;
161 template <typename U = T>
162 typename std::enable_if_t<std::is_class_v<U>, T&>
163 append (T&& value) ;
171 BufferCast<T>& erase (unsigned long long index, unsigned long long count = 1ull)
180 Buffer relinquishBufferOwnership () ;
188 typename
189 BufferCastDataDescriptor<T> relinquishDataOwnership () ;
190
191 public :
192
193 // Operators
200 T& operator[] (unsigned long long index) ;
207 const T& operator[] (unsigned long long index) const ;
214 BufferCast<T>& operator= (const BufferCast<T>& other) noexcept ;
221 template <typename U = T>
222 std::enable_if_t<!std::is_class_v<U> || std::is_move_assignable_v<U>, BufferCast<T>&>
223 operator= (BufferCast<T>&& other) noexcept ;
224
225 public :
226
227 // Templated constructors
233 template <std::size_t S>
234 BufferCast (const std::array<T, S>& array) noexcept ;
235
241 template <typename U, std::size_t S>
242 BufferCast (const std::array<U, S>& array) noexcept ;
243
249 BufferCast (const std::vector<T>& vec) noexcept ;
250
256 template <typename U>
257 BufferCast (const std::vector<U>& vec) noexcept ;
263 BufferCast (std::initializer_list<T> args) noexcept ;
269 BufferCast (std::initializer_list<U> args) noexcept ;
270 } ;
271 }
nkMemory::BufferCast::getSize
unsigned long long getSize() const
nkMemory::BufferCast::append
T & append(const T &value)
nkMemory::BufferCast::back
T & back()
nkMemory::BufferCast::clear
BufferCast< T > & clear()
nkMemory::BufferCast::getData
T * getData() const
nkMemory::BufferCast::relinquishDataOwnership
BufferCastDataDescriptor< T > relinquishDataOwnership()
nkMemory::BufferCast::BufferCast
BufferCast() noexcept=default
nkMemory::BufferCast::resize
BufferCast< T > & resize(unsigned long long size)
nkMemory::BufferCast::empty
bool empty() const
nkMemory::Buffer
A buffer holding binary data.
Definition: Buffer.h:32
nkMemory::BufferCast::front
T & front()
nkMemory::BufferCast
Holds a Buffer and make it easy to cast the binary data.
Definition: BufferCast.h:18
nkMemory::BufferCast::end
T * end()
nkMemory::BufferCast::erase
BufferCast< T > & erase(unsigned long long index, unsigned long long count=1ull) Buffer relinquishBufferOwnership()
nkMemory::BufferCast::begin
T * begin()
nkMemory
Encompasses all API of component NilkinsMemory.
Definition: Allocator.h:7